import React, { useEffect, useState } from 'react'
import styles from "./hospitalAnnouncement.module.scss"
import { Button, SearchBar, Space, Toast } from 'antd-mobile'
import { List, Image } from 'antd-mobile'
import api from "../../api"
import utils from '../../untils/tool'
import { useNavigate } from 'react-router-dom'
export default function index() {
    const navigator = useNavigate()
    const [list, setList] = useState([])
    function getHospitalAnnouncement(title = "") {
        let params = {
            title
        }
        api.getHospitalAnnouncement(params).then(res => {
            setList(res.list)
        })
    }
    useEffect(() => {
        getHospitalAnnouncement()
    }, [])

    return (
        <div className={styles.content}>
            <SearchBar onSearch={getHospitalAnnouncement} className={styles.SearchBar} placeholder='请输入公告标题' />
            <List>
                {list.map(item => (
                    <List.Item
                        onClick={() => {
                            navigator(`/home/hospitalAnnouncementDesc/${item.id}`)
                        }}
                        key={item.id}
                        prefix={
                            <Image
                                src={item.image}
                                fit='cover'
                                width={130}
                                height={130}
                            />
                        }
                        description={utils.getContent(item.content)}
                    >
                        {item.title}
                    </List.Item>
                ))}
            </List>
        </div>
    )
}
